﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MisDLL;
using IBLL;
using System.Data;
using System.Data.Common;

namespace MisBLL
{
    class InvoiceDAO : MarshalByRefObject, IInvoice
    {
        protected MisEntity.DataEntityDataContext Ctx = new MisEntity.DataEntityDataContext();
        protected DbHelper dbHelper = new DbHelper();

        //生成发票
        public string Insert(MisEntity.Invoice L_Invoice)
        {
            DbCommand command=dbHelper.GetStoredProcedureCommond("SP_INSERT_INVOICE2");
            dbHelper.AddOutParameter(command, "@IID", DbType.StringFixedLength, 20);
            dbHelper.AddInParameter(command, "@JE_HS", DbType.Decimal, L_Invoice.je_hs);
            dbHelper.AddInParameter(command, "@JE_FS", DbType.Decimal, L_Invoice.je_fs);
            dbHelper.AddInParameter(command, "@F1", DbType.StringFixedLength, "Y");
            dbHelper.AddInParameter(command, "@OPER", DbType.String, L_Invoice.OPER);
            dbHelper.AddInParameter(command, "@NO_BEI", DbType.String, L_Invoice.bei);
            dbHelper.AddInParameter(command, "@GOODS", DbType.String, L_Invoice.goods);
            dbHelper.AddInParameter(command, "@je_cas", DbType.Decimal, L_Invoice.je_cas);
            dbHelper.AddInParameter(command, "@cus_id", DbType.StringFixedLength, L_Invoice.DM);
            dbHelper.AddInParameter(command, "@cus_dep", DbType.StringFixedLength, L_Invoice.ID);
            dbHelper.ExecuteNonQuery(command);
            return dbHelper.GetParameter(command, "@IID").Value.ToString().Trim(); 
        }
    }
}
